package com.newbingo.service;

import java.util.List;

import com.newbingo.dao.imple.IGameDao;
import com.newbingo.dto.imple.IGameDto;
import com.newbingo.entity.Game;
import com.newbingo.entity.GamePlay;
import com.newbingo.service.imple.IGameService;
import com.newbingo.util.Pager;

public class GameService implements IGameService {
	private IGameDao gameDao = null;
	private IGameDto gameDto = null;

	public IGameDto getGameDto() {
		return gameDto;
	}

	public void setGameDto(IGameDto gameDto) {
		this.gameDto = gameDto;
	}

	public void setGameDao(IGameDao gameDao) {
		this.gameDao = gameDao;
	}

	public IGameDao getGameDao() {
		return gameDao;
	}

	/*
	 *新增游戏方法
	 *@param game 游戏实体对象
	 */
	public void createGame(Game game) {
		gameDao.save(game);
	}
	
	/* 
	 * 删除游戏
	 */
	public void delete(Game game) {
		// TODO Auto-generated method stub
		gameDao.delete(game);
	}
	
	/*
	 * 查询所有游戏信息,返回的是游戏的DTO对象
	 */
	public List findAllDto() {
		return gameDto.findAllGames();
	}
	
	public List findAll(){
		return gameDao.findAll();
	}
	
	
	/*
	 * 根据游戏名称查询
	 */
	public List<Game> findByGamename(Object gamename) {
		return gameDao.findByGamename(gamename);
	}

	/* 
	 * 根据Id查询游戏
	 */
	public Game findById(Integer id) {
		// TODO Auto-generated method stub
		return gameDao.findById(id);
	}

	/*
	 * 游戏修改
	 */
	public void updateGame(Game game) {
		gameDao.merge(game);
	}
    /*
	 *分页查询
	 *@param type 游戏类型
	 */
	public Pager findByPage(int start, int limit, Object type) {
		return gameDao.findByPage(start, limit, type);
	}

	/*
	 *根据type查询
	 */
	public List findByType(Object type) {
		return gameDao.findByType(type);
	}


}
